# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : p17.py
# @Time     : 2024/5/10 22:51
# @Author   : Robot-Zsj
"""
description:

求幸存数之和

https://fcqian.blog.csdn.net/article/details/134883009?spm=1001.2014.3001.5502

i:
1,2,3,4,5,6,7,8,9
4
3

o:
13

"""
nums = list(map(int, input().split(",")))
jump = int(input())
left = int(input())


def sumOfLeft(nums, jump, left):
    start = 1
    while len(nums) > left:
        start += jump
        start %= len(nums)
        nums.pop(start)
    return sum(nums)


print(sumOfLeft(nums, jump, left))
